package com.odianyun.springboottest.web;

import com.odianyun.springboottest.model.po.Article;
import com.odianyun.springboottest.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @author: EDZ
 * @time: 20:04
 * @date: 2021/7/19
 */
@RestController
@RequestMapping("article")
@Api(tags = {"文章操作接口"})
public class ArticleController {

    @Resource
    private ArticleService articleService;

    @ApiOperation(value = "保存", notes = "前端文章管理-新增文章")
    @PostMapping("save")
    public String save(@RequestBody Article article){
        String id = articleService.save(article);
        return id;
    }


//    @ApiIgnore(value = "插入")
    @PostMapping("insert")
    public String insert(@RequestBody Article article){
        String id = articleService.insert(article);
        return id;
    }

    @PostMapping("batchSave")
    public String batchSave(@RequestBody List<Article> articleList){
        articleService.batchSave(articleList);
        return "success";
    }
}
